home *** CD-ROM | disk | FTP | other *** search
/ Eagles Nest BBS 8 / Eagles_Nest_Mac_Collection_Disc_8.TOAST / Developer Environments / AAISProlog / Examples / define_print ex.p < prev    next >
MacBinary  |  1992-03-23  |  8.0 KB  |  [TEXT/AIFC]

open in: MacOS 8.1     |     Win98     |     DOS

browse contents    |     view JSON data     |     view as text


This file was processed as: MacBinary (archive/macBinary).

ConfidenceProgramDetectionMatch TypeSupport
66% dexvert ZX81 Sinclair BASIC (image/sinclairBASIC) ext Supported
10% dexvert MacBinary (archive/macBinary) fallback Supported
1% dexvert bsdiff patch (other/bsdiffPatch) ext Unsupported
1% dexvert imgdiff patch (other/imgdiffPatch) ext Unsupported
1% dexvert WSUS Patch Storage File (other/wsusPatchStorageFile) ext Unsupported
1% dexvert Text File (text/txt) fallback Supported
100% file MacBinary II, inited, Mon Mar 23 00:04:18 1992, modified Mon Mar 23 00:04:18 1992, creator 'AIFC', type ASCII, 7609 bytes "define_print ex.p" , at 0x1e39 380 bytes resource default (weak)
99% file data default
74% TrID Macintosh plain text (MacBinary) default
25% TrID MacBinary 2 default (weak)
100% siegfried fmt/1762 MacBinary (II) default
100% lsar MacBinary default


id metadata
keyvalue
macFileType[TEXT]
macFileCreator[AIFC]



hex view
+--------+-------------------------+-------------------------+--------+--------+
|00000000| 00 11 64 65 66 69 6e 65 | 5f 70 72 69 6e 74 20 65 |..define|_print e|
|00000010| 78 2e 70 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |x.p.....|........|
|00000020| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000030| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00000040| 00 54 45 58 54 41 49 46 | 43 01 00 00 00 00 00 00 |.TEXTAIF|C.......|
|00000050| 00 00 00 00 00 1d b9 00 | 00 01 7c a5 f3 17 52 a5 |........|..|...R.|
|00000060| f3 17 52 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |..R.....|........|
|00000070| 00 00 00 00 00 00 00 00 | 00 00 81 81 58 e8 00 00 |........|....X...|
|00000080| 2f 2a 0d a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |/*......|........|
|00000090| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|000000a0| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|000000b0| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|000000c0| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 0d |........|........|
|000000d0| 64 65 66 69 6e 65 5f 70 | 72 69 6e 74 20 65 78 2e |define_p|rint ex.|
|000000e0| 70 3a 20 0d 09 54 68 69 | 73 20 66 69 6c 65 20 69 |p: ..Thi|s file i|
|000000f0| 6c 6c 75 73 74 72 61 74 | 65 73 20 61 20 73 69 6d |llustrat|es a sim|
|00000100| 70 6c 65 20 65 78 61 6d | 70 6c 65 20 6f 66 20 75 |ple exam|ple of u|
|00000110| 73 69 6e 67 20 74 68 65 | 20 0d 09 64 65 66 69 6e |sing the| ..defin|
|00000120| 65 20 70 72 69 6e 74 20 | 66 75 6e 63 74 69 6f 6e |e print |function|
|00000130| 20 77 69 74 68 20 70 72 | 65 74 74 79 70 72 69 6e | with pr|ettyprin|
|00000140| 74 20 63 6f 6d 6d 61 6e | 64 73 2e 0d 0d 43 6f 70 |t comman|ds...Cop|
|00000150| 79 72 69 67 68 74 2c 20 | a9 20 31 39 39 32 20 41 |yright, |. 1992 A|
|00000160| 64 76 61 6e 63 65 64 20 | 41 2e 20 49 2e 20 53 79 |dvanced |A. I. Sy|
|00000170| 73 74 65 6d 73 2c 20 49 | 6e 63 2e 0d 41 6c 6c 20 |stems, I|nc..All |
|00000180| 72 69 67 68 74 73 20 72 | 65 73 65 72 76 65 64 2e |rights r|eserved.|
|00000190| 0d 54 68 69 73 20 66 69 | 6c 65 20 6d 61 79 20 6e |.This fi|le may n|
|000001a0| 6f 74 20 62 65 20 63 6f | 70 69 65 64 20 6f 72 20 |ot be co|pied or |
|000001b0| 64 69 73 74 72 69 62 75 | 74 65 64 20 77 69 74 68 |distribu|ted with|
|000001c0| 6f 75 74 20 74 68 65 20 | 77 72 69 74 74 65 6e 0d |out the |written.|
|000001d0| 70 65 72 6d 69 73 73 69 | 6f 6e 20 6f 66 20 41 64 |permissi|on of Ad|
|000001e0| 76 61 6e 63 65 64 20 41 | 2e 20 49 2e 20 53 79 73 |vanced A|. I. Sys|
|000001f0| 74 65 6d 73 2c 20 49 6e | 63 2e 0d a5 a5 a5 a5 a5 |tems, In|c.......|
|00000200| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|00000210| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|00000220| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|00000230| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|00000240| a5 a5 a5 a5 a5 a5 a5 0d | 48 65 72 65 20 77 65 20 |........|Here we |
|00000250| 64 65 66 69 6e 65 20 70 | 72 69 6e 74 20 63 6f 6d |define p|rint com|
|00000260| 6d 61 6e 64 73 20 66 6f | 72 20 3b 2f 32 20 61 6e |mands fo|r ;/2 an|
|00000270| 64 20 3a 2d 2f 32 2e 0d | 0d 54 6f 20 74 65 73 74 |d :-/2..|.To test|
|00000280| 20 74 68 69 73 20 66 69 | 6c 65 2c 20 63 6f 6e 73 | this fi|le, cons|
|00000290| 75 6c 74 20 69 74 3b 20 | 75 73 65 20 63 6f 6d 6d |ult it; |use comm|
|000002a0| 61 6e 64 2d 79 20 6f 72 | 20 74 68 65 20 50 72 6f |and-y or| the Pro|
|000002b0| 6c 6f 67 20 72 65 63 6f | 6e 73 75 6c 74 20 63 6f |log reco|nsult co|
|000002c0| 6d 6d 61 6e 64 2e 0d 20 | 0d 20 54 68 65 6e 20 65 |mmand.. |. Then e|
|000002d0| 78 65 63 75 74 65 20 66 | 6f 6c 6c 6f 77 69 6e 67 |xecute f|ollowing|
|000002e0| 20 63 6f 64 65 3a 0d 20 | 0d 20 3a 2d 20 6c 69 73 | code:. |. :- lis|
|000002f0| 74 69 6e 67 28 5b 70 72 | 69 6e 74 5f 72 75 6c 65 |ting([pr|int_rule|
|00000300| 2c 20 70 72 69 6e 74 5f | 6f 72 5d 29 2e 0d 0d 54 |, print_|or])...T|
|00000310| 68 69 73 20 66 69 6c 65 | 20 73 68 6f 77 73 20 68 |his file| shows h|
|00000320| 6f 77 20 74 6f 20 6d 61 | 6b 65 20 63 6f 6d 70 6c |ow to ma|ke compl|
|00000330| 65 78 20 70 72 69 6e 74 | 20 63 6f 6d 6d 61 6e 64 |ex print| command|
|00000340| 73 20 62 79 20 63 72 65 | 61 74 69 6e 67 20 70 72 |s by cre|ating pr|
|00000350| 69 6e 74 5f 63 6f 6d 6d | 61 6e 64 5f 62 6f 78 20 |int_comm|and_box |
|00000360| 6f 62 6a 65 63 74 73 0d | 77 68 69 63 68 20 63 61 |objects.|which ca|
|00000370| 6e 20 74 68 65 6e 20 68 | 61 76 65 20 64 65 74 61 |n then h|ave deta|
|00000380| 69 6c 65 64 20 63 6f 64 | 65 20 65 78 65 63 75 74 |iled cod|e execut|
|00000390| 65 64 20 69 6e 73 69 64 | 65 20 70 70 70 72 69 6e |ed insid|e ppprin|
|000003a0| 74 5f 77 69 74 68 5f 6c | 65 66 74 5f 6d 61 72 67 |t_with_l|eft_marg|
|000003b0| 69 6e 20 61 6e 64 0d 70 | 72 69 6e 74 5f 77 69 74 |in and.p|rint_wit|
|000003c0| 68 5f 70 72 65 63 65 64 | 65 6e 63 65 2e 20 20 54 |h_preced|ence. T|
|000003d0| 68 65 73 65 20 66 75 6e | 63 74 69 6f 6e 73 20 6f |hese fun|ctions o|
|000003e0| 6e 6c 79 20 74 61 6b 65 | 20 6f 62 6a 65 63 74 73 |nly take| objects|
|000003f0| 20 74 6f 20 70 72 69 6e | 74 2c 20 6e 6f 74 20 63 | to prin|t, not c|
|00000400| 6f 64 65 20 74 6f 20 62 | 65 20 72 75 6e 2e 0d 0d |ode to b|e run...|
|00000410| 54 68 65 20 62 75 69 6c | 74 2d 69 6e 20 76 65 72 |The buil|t-in ver|
|00000420| 73 69 6f 6e 73 20 66 6f | 72 20 74 68 65 73 65 20 |sions fo|r these |
|00000430| 74 68 69 6e 67 73 20 61 | 6c 73 6f 20 68 61 76 65 |things a|lso have|
|00000440| 20 68 6f 6f 6b 73 20 69 | 6e 74 6f 20 74 68 65 20 | hooks i|nto the |
|00000450| 50 72 6f 6c 6f 67 20 6b | 65 72 6e 65 6c 0d 74 6f |Prolog k|ernel.to|
|00000460| 20 64 65 74 65 72 6d 69 | 6e 65 20 74 68 65 20 6e | determi|ne the n|
|00000470| 61 6d 65 73 20 6f 66 20 | 76 61 72 69 61 62 6c 65 |ames of |variable|
|00000480| 73 20 77 68 65 6e 20 70 | 72 69 6e 74 69 6e 67 20 |s when p|rinting |
|00000490| 72 75 6c 65 73 20 66 72 | 6f 6d 20 6c 69 73 74 69 |rules fr|om listi|
|000004a0| 6e 67 2e 20 20 0d 54 68 | 69 73 20 69 73 20 6e 6f |ng. .Th|is is no|
|000004b0| 74 20 61 76 61 69 6c 61 | 62 6c 65 20 6f 72 20 70 |t availa|ble or p|
|000004c0| 6f 73 73 69 62 6c 65 20 | 68 65 72 65 2e 0d 0d 41 |ossible |here...A|
|000004d0| 6c 73 6f 2c 20 74 68 69 | 73 20 66 69 6c 65 20 6d |lso, thi|s file m|
|000004e0| 61 6b 65 73 20 61 6c 6c | 20 76 61 72 69 61 62 6c |akes all| variabl|
|000004f0| 65 73 20 70 72 69 6e 74 | 20 61 73 20 5f 56 6e 6e |es print| as _Vnn|
|00000500| 6e 20 61 6e 64 20 6e 6f | 74 20 61 73 20 74 68 65 |n and no|t as the|
|00000510| 20 64 65 66 61 75 6c 74 | 20 6e 75 6d 62 65 72 0d | default| number.|
|00000520| 49 6e 20 74 68 69 73 20 | 77 61 79 20 69 74 20 67 |In this |way it g|
|00000530| 65 74 73 20 61 72 6f 75 | 6e 64 20 74 68 65 20 6c |ets arou|nd the l|
|00000540| 69 6d 69 74 61 74 69 6f | 6e 73 20 6f 66 20 74 68 |imitatio|ns of th|
|00000550| 65 20 70 72 65 74 74 79 | 20 70 72 69 6e 74 20 66 |e pretty| print f|
|00000560| 75 6e 63 74 69 6f 6e 73 | 2e 20 20 0d 54 6f 20 64 |unctions|. .To d|
|00000570| 6f 20 69 74 73 20 77 6f | 72 6b 2c 20 69 74 20 75 |o its wo|rk, it u|
|00000580| 73 65 73 20 73 65 74 5f | 66 69 65 6c 64 2e 20 20 |ses set_|field. |
|00000590| 53 65 74 5f 66 69 65 6c | 64 20 63 6f 70 69 65 73 |Set_fiel|d copies|
|000005a0| 20 76 61 72 69 61 62 6c | 65 73 20 61 6e 64 20 6c | variabl|es and l|
|000005b0| 6f 73 65 20 74 68 65 69 | 72 20 75 6e 69 71 75 65 |ose thei|r unique|
|000005c0| 20 69 64 65 6e 74 69 74 | 79 2e 20 0d 54 68 75 73 | identit|y. .Thus|
|000005d0| 20 6d 69 78 69 6e 67 20 | 74 68 69 73 20 77 69 74 | mixing |this wit|
|000005e0| 68 20 74 68 65 20 64 65 | 66 61 75 6c 74 20 70 72 |h the de|fault pr|
|000005f0| 69 6e 74 69 6e 67 20 62 | 79 20 74 68 65 20 50 72 |inting b|y the Pr|
|00000600| 6f 6c 6f 67 20 73 79 73 | 74 65 6d 20 0d 77 69 6c |olog sys|tem .wil|
|00000610| 6c 20 68 61 76 65 20 64 | 69 66 66 65 72 65 6e 74 |l have d|ifferent|
|00000620| 20 74 65 72 6d 73 20 75 | 73 65 64 20 66 6f 72 20 | terms u|sed for |
|00000630| 74 68 65 20 73 61 6d 65 | 20 75 6e 62 6f 75 6e 64 |the same| unbound|
|00000640| 20 76 61 72 69 61 62 6c | 65 73 2e 0d a5 a5 a5 a5 | variabl|es......|
|00000650| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|00000660| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|00000670| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|00000680| a5 a5 a5 a5 a5 a5 a5 a5 | a5 a5 a5 a5 a5 a5 a5 a5 |........|........|
|00000690| a5 a5 a5 a5 a5 a5 a5 a5 | 0d 20 2a 20 4c 69 6d 69 |........|. * Limi|
|000006a0| 74 61 74 69 6f 6e 73 20 | 6f 66 20 74 68 65 20 64 |tations |of the d|
|000006b0| 65 66 69 6e 65 5f 70 72 | 69 6e 74 2f 70 72 65 74 |efine_pr|int/pret|
|000006c0| 74 79 20 70 72 69 6e 74 | 20 66 75 6e 63 74 69 6f |ty print| functio|
|000006d0| 6e 73 20 70 72 6f 76 69 | 64 65 64 3a 0d 20 2a 09 |ns provi|ded:. *.|
|000006e0| 54 68 65 72 65 20 69 73 | 20 6e 6f 20 64 69 72 65 |There is| no dire|
|000006f0| 63 74 20 77 61 79 20 74 | 6f 20 72 75 6e 20 66 75 |ct way t|o run fu|
|00000700| 6e 63 74 69 6f 6e 73 20 | 77 68 65 6e 20 74 68 65 |nctions |when the|
|00000710| 20 6c 65 66 74 20 6d 61 | 72 67 69 6e 20 6f 72 20 | left ma|rgin or |
|00000720| 70 72 65 63 65 64 65 6e | 63 65 20 6c 65 76 65 6c |preceden|ce level|
|00000730| 20 69 73 20 73 65 74 2e | 0d 20 2a 09 54 68 69 73 | is set.|. *.This|
|00000740| 20 65 78 61 6d 70 6c 65 | 20 73 68 6f 77 73 20 61 | example| shows a|
|00000750| 20 77 61 79 20 61 72 6f | 75 6e 64 20 74 68 69 73 | way aro|und this|
|00000760| 2c 20 62 75 74 20 74 68 | 69 73 20 77 61 79 20 68 |, but th|is way h|
|00000770| 61 73 20 74 68 65 20 70 | 72 6f 62 6c 65 6d 20 74 |as the p|roblem t|
|00000780| 68 61 74 20 76 61 72 69 | 61 62 6c 65 73 20 6d 75 |hat vari|ables mu|
|00000790| 73 74 20 62 65 0d 20 2a | 09 72 65 6e 61 6d 65 64 |st be. *|.renamed|
|000007a0| 20 77 69 74 68 20 73 6f | 6d 65 74 68 69 6e 67 20 | with so|mething |
|000007b0| 6c 69 6b 65 20 6e 75 6d | 62 65 72 76 61 72 73 2e |like num|bervars.|
|000007c0| 20 20 54 68 75 73 20 76 | 61 72 69 61 62 6c 65 73 | Thus v|ariables|
|000007d0| 20 61 72 65 20 6e 6f 74 | 20 61 73 73 69 67 6e 65 | are not| assigne|
|000007e0| 64 20 74 68 65 20 73 61 | 6d 65 20 6e 75 6d 62 65 |d the sa|me numbe|
|000007f0| 72 73 0d 20 2a 09 61 73 | 20 62 79 20 74 68 65 20 |rs. *.as| by the |
|00000800| 62 75 69 6c 74 2d 69 6e | 20 70 72 69 6e 74 65 72 |built-in| printer|
|00000810| 20 69 66 20 74 68 69 73 | 20 69 73 20 64 6f 6e 65 | if this| is done|
|00000820| 2e 0d 20 2a 20 59 6f 75 | 20 63 6f 75 6c 64 20 64 |.. * You| could d|
|00000830| 65 66 69 6e 65 20 61 20 | 64 65 66 61 75 6c 74 20 |efine a |default |
|00000840| 70 6f 72 74 72 61 79 20 | 63 6c 61 75 73 65 20 66 |portray |clause f|
|00000850| 6f 72 20 69 6e 73 74 61 | 6e 63 65 73 20 61 6e 64 |or insta|nces and|
|00000860| 20 6c 69 73 74 73 20 77 | 68 69 63 68 20 77 6f 75 | lists w|hich wou|
|00000870| 6c 64 20 6e 75 6d 62 65 | 72 76 61 72 73 20 74 68 |ld numbe|rvars th|
|00000880| 65 20 0d 20 2a 09 63 6c | 61 75 73 65 20 66 69 72 |e . *.cl|ause fir|
|00000890| 73 74 20 62 65 66 6f 72 | 65 20 70 72 69 6e 74 69 |st befor|e printi|
|000008a0| 6e 67 20 61 6c 6c 20 74 | 68 65 20 73 75 62 70 61 |ng all t|he subpa|
|000008b0| 72 74 73 2e 20 20 44 6f | 20 6e 6f 74 20 68 61 76 |rts. Do| not hav|
|000008c0| 65 20 69 74 20 63 61 6c | 6c 65 64 20 70 72 69 6e |e it cal|led prin|
|000008d0| 74 20 64 69 72 65 63 74 | 6c 79 20 62 75 74 20 65 |t direct|ly but e|
|000008e0| 69 74 68 65 72 20 63 61 | 6c 6c 0d 20 2a 09 70 6f |ither ca|ll. *.po|
|000008f0| 72 74 72 61 79 20 6f 72 | 20 69 66 20 70 6f 72 74 |rtray or| if port|
|00000900| 72 61 79 20 66 61 69 6c | 73 2c 20 70 72 69 6e 74 |ray fail|s, print|
|00000910| 20 74 68 65 20 66 75 6e | 63 74 6f 72 20 61 6e 64 | the fun|ctor and|
|00000920| 20 63 61 6c 6c 20 70 72 | 69 6e 74 20 6f 6e 20 65 | call pr|int on e|
|00000930| 61 63 68 20 73 75 62 20 | 61 72 67 75 6d 65 6e 74 |ach sub |argument|
|00000940| 20 69 6e 20 62 65 74 77 | 65 65 6e 2e 0d 20 2a 09 | in betw|een.. *.|
|00000950| 57 65 20 64 6f 20 6e 6f | 74 20 69 6c 6c 75 73 74 |We do no|t illust|
|00000960| 72 61 74 65 20 74 68 69 | 73 20 69 6e 20 74 68 69 |rate thi|s in thi|
|00000970| 73 20 65 78 61 6d 70 6c | 65 2e 0d 20 2a 20 6c 69 |s exampl|e.. * li|
|00000980| 73 74 69 6e 67 20 75 73 | 65 73 20 70 72 69 6e 74 |sting us|es print|
|00000990| 2e 20 20 54 68 65 20 77 | 72 69 74 65 71 20 62 75 |. The w|riteq bu|
|000009a0| 69 6c 74 2d 69 6e 20 74 | 6f 20 74 68 65 20 6b 65 |ilt-in t|o the ke|
|000009b0| 72 6e 65 6c 20 63 61 6e | 20 61 63 63 65 73 73 20 |rnel can| access |
|000009c0| 76 61 72 69 61 62 6c 65 | 20 6e 61 6d 65 73 20 66 |variable| names f|
|000009d0| 6f 72 20 72 75 6c 65 73 | 20 77 68 65 6e 20 63 61 |or rules| when ca|
|000009e0| 6c 6c 65 64 0d 20 2a 09 | 62 79 20 6c 69 73 74 69 |lled. *.|by listi|
|000009f0| 6e 67 2e 20 20 20 48 6f | 77 65 76 65 72 2c 79 6f |ng. Ho|wever,yo|
|00000a00| 75 72 20 6f 77 6e 20 70 | 72 69 6e 74 20 66 75 6e |ur own p|rint fun|
|00000a10| 63 74 69 6f 6e 20 64 65 | 66 69 6e 65 64 20 66 6f |ction de|fined fo|
|00000a20| 72 20 3a 2d 2f 32 20 61 | 73 20 64 6f 6e 65 20 69 |r :-/2 a|s done i|
|00000a30| 6e 20 74 68 69 73 0d 20 | 2a 09 66 69 6c 65 2c 20 |n this. |*.file, |
|00000a40| 63 61 6e 6e 6f 74 20 61 | 63 63 65 73 73 20 74 68 |cannot a|ccess th|
|00000a50| 65 73 65 20 69 6e 74 65 | 72 6e 61 6c 20 76 61 72 |ese inte|rnal var|
|00000a60| 69 61 62 6c 65 20 6e 61 | 6d 65 73 2e 20 20 54 68 |iable na|mes. Th|
|00000a70| 65 72 65 20 69 73 20 6e | 6f 20 77 61 79 20 66 6f |ere is n|o way fo|
|00000a80| 72 20 50 72 6f 6c 6f 67 | 20 74 6f 20 67 65 74 20 |r Prolog| to get |
|00000a90| 61 74 20 74 68 65 73 65 | 0d 20 2a 09 69 6e 74 65 |at these|. *.inte|
|00000aa0| 72 6e 61 6c 20 76 61 72 | 69 61 62 6c 65 20 6e 61 |rnal var|iable na|
|00000ab0| 6d 65 73 20 61 73 73 6f | 63 69 61 74 65 64 20 77 |mes asso|ciated w|
|00000ac0| 69 74 68 20 74 68 65 20 | 61 73 73 65 72 74 65 64 |ith the |asserted|
|00000ad0| 20 72 75 6c 65 20 6f 72 | 20 66 61 63 74 2e 20 20 | rule or| fact. |
|00000ae0| 4f 6e 6c 79 20 6c 69 73 | 74 69 6e 67 20 63 61 6e |Only lis|ting can|
|00000af0| 20 61 63 63 65 73 73 20 | 74 68 65 73 65 2e 0d 20 | access |these.. |
|00000b00| 2a 20 0d 20 2a 20 57 61 | 72 6e 69 6e 67 3a 20 69 |* . * Wa|rning: i|
|00000b10| 66 20 70 6f 72 74 72 61 | 79 20 66 61 69 6c 73 2c |f portra|y fails,|
|00000b20| 20 70 72 69 6e 74 20 77 | 69 6c 6c 20 63 61 6c 6c | print w|ill call|
|00000b30| 20 77 72 69 74 65 71 20 | 74 6f 20 77 72 69 74 65 | writeq |to write|
|00000b40| 20 74 68 65 20 6f 75 74 | 70 75 74 2e 0d 20 2a 2f | the out|put.. */|
|00000b50| 0d 0d 2f 2a 0d 20 2a 20 | 70 70 70 72 69 6e 74 5f |../*. * |ppprint_|
|00000b60| 77 69 74 68 5f 6c 65 66 | 74 5f 6d 61 72 67 69 6e |with_lef|t_margin|
|00000b70| 2c 20 70 72 69 6e 74 5f | 77 69 74 68 5f 70 72 65 |, print_|with_pre|
|00000b80| 63 65 64 65 6e 63 65 2c | 20 70 70 70 72 69 6e 74 |cedence,| ppprint|
|00000b90| 5f 77 69 74 68 5f 70 72 | 65 63 65 64 65 6e 63 65 |_with_pr|ecedence|
|00000ba0| 20 6f 6e 6c 79 0d 20 2a | 09 74 61 6b 65 20 69 74 | only. *|.take it|
|00000bb0| 65 6d 73 20 74 6f 20 70 | 72 69 6e 74 2c 20 6e 6f |ems to p|rint, no|
|00000bc0| 74 20 66 75 6e 63 74 69 | 6f 6e 73 20 74 6f 20 62 |t functi|ons to b|
|00000bd0| 65 20 72 75 6e 2e 20 20 | 49 6e 20 6f 72 64 65 72 |e run. |In order|
|00000be0| 20 74 6f 20 68 61 76 65 | 20 61 20 66 75 6e 63 74 | to have| a funct|
|00000bf0| 69 6f 6e 20 72 75 6e 2c | 0d 20 2a 09 77 65 20 61 |ion run,|. *.we a|
|00000c00| 72 65 20 67 6f 69 6e 67 | 20 74 6f 20 63 72 65 61 |re going| to crea|
|00000c10| 74 65 20 61 20 70 72 69 | 6e 74 5f 63 6f 6d 6d 61 |te a pri|nt_comma|
|00000c20| 6e 64 5f 62 6f 78 20 6f | 62 6a 65 63 74 2c 20 77 |nd_box o|bject, w|
|00000c30| 68 6f 73 65 20 70 72 69 | 6e 74 20 66 75 6e 63 74 |hose pri|nt funct|
|00000c40| 69 6f 6e 20 77 69 6c 6c | 20 62 65 20 74 68 65 20 |ion will| be the |
|00000c50| 66 75 6e 63 74 69 6f 6e | 0d 20 2a 09 74 6f 20 72 |function|. *.to r|
|00000c60| 75 6e 2e 0d 20 2a 20 54 | 68 69 73 20 69 73 20 61 |un.. * T|his is a|
|00000c70| 20 73 69 6d 70 6c 65 20 | 74 72 69 63 6b 20 77 65 | simple |trick we|
|00000c80| 20 61 72 65 20 75 73 69 | 6e 67 20 77 69 74 68 20 | are usi|ng with |
|00000c90| 68 61 72 64 77 69 72 65 | 64 20 73 70 65 63 69 66 |hardwire|d specif|
|00000ca0| 69 63 20 63 6f 6d 6d 61 | 6e 64 73 20 66 6f 72 20 |ic comma|nds for |
|00000cb0| 6f 75 72 20 65 78 61 6d | 70 6c 65 20 69 6e 20 74 |our exam|ple in t|
|00000cc0| 68 69 73 0d 20 2a 09 66 | 69 6c 65 2e 0d 20 2a 2f |his. *.f|ile.. */|
|00000cd0| 0d 3a 2d 20 63 72 65 61 | 74 65 28 62 61 73 69 63 |.:- crea|te(basic|
|00000ce0| 5f 74 79 70 65 2c 20 5f | 2c 20 70 72 69 6e 74 5f |_type, _|, print_|
|00000cf0| 63 6f 6d 6d 61 6e 64 5f | 62 6f 78 2c 20 70 74 72 |command_|box, ptr|
|00000d00| 2c 0d 09 5b 63 6f 6d 6d | 61 6e 64 5f 6e 75 6d 62 |,..[comm|and_numb|
|00000d10| 65 72 20 3d 20 77 6f 72 | 64 2c 0d 09 20 69 74 65 |er = wor|d,.. ite|
|00000d20| 6d 20 3d 20 70 72 6f 6c | 6f 67 5f 64 61 74 61 5d |m = prol|og_data]|
|00000d30| 2c 0d 09 73 65 74 5f 70 | 63 62 5f 69 6e 66 6f 2f |,..set_p|cb_info/|
|00000d40| 33 2c 0d 09 74 72 75 65 | 29 2e 0d 09 0d 73 65 74 |3,..true|)....set|
|00000d50| 5f 70 63 62 5f 69 6e 66 | 6f 28 50 43 42 2c 20 4e |_pcb_inf|o(PCB, N|
|00000d60| 65 77 43 6f 6d 6d 61 6e | 64 4e 75 6d 62 65 72 2c |ewComman|dNumber,|
|00000d70| 20 4e 65 77 49 74 65 6d | 29 20 3a 2d 0d 09 50 43 | NewItem|) :-..PC|
|00000d80| 42 5e 2e 63 6f 6d 6d 61 | 6e 64 5f 6e 75 6d 62 65 |B^.comma|nd_numbe|
|00000d90| 72 20 69 73 20 4e 65 77 | 43 6f 6d 6d 61 6e 64 4e |r is New|CommandN|
|00000da0| 75 6d 62 65 72 2c 0d 09 | 73 65 74 5f 66 69 65 6c |umber,..|set_fiel|
|00000db0| 64 28 50 43 42 2c 20 69 | 74 65 6d 2c 20 4e 65 77 |d(PCB, i|tem, New|
|00000dc0| 49 74 65 6d 29 2e 0d 0d | 70 72 69 6e 74 5f 63 6f |Item)...|print_co|
|00000dd0| 6d 6d 61 6e 64 28 50 43 | 42 29 20 3a 2d 0d 09 50 |mmand(PC|B) :-..P|
|00000de0| 72 69 6e 74 43 6f 6d 6d | 61 6e 64 20 69 73 20 50 |rintComm|and is P|
|00000df0| 43 42 5e 2e 63 6f 6d 6d | 61 6e 64 5f 6e 75 6d 62 |CB^.comm|and_numb|
|00000e00| 65 72 2c 0d 09 67 65 74 | 5f 66 69 65 6c 64 28 50 |er,..get|_field(P|
|00000e10| 43 42 2c 20 69 74 65 6d | 2c 20 50 72 69 6e 74 49 |CB, item|, PrintI|
|00000e20| 74 65 6d 29 2c 0d 09 70 | 72 69 6e 74 5f 63 6f 6d |tem),..p|rint_com|
|00000e30| 6d 61 6e 64 28 50 72 69 | 6e 74 43 6f 6d 6d 61 6e |mand(Pri|ntComman|
|00000e40| 64 2c 20 50 72 69 6e 74 | 49 74 65 6d 29 2e 0d 09 |d, Print|Item)...|
|00000e50| 0d 3a 2d 20 64 65 66 69 | 6e 65 5f 70 72 69 6e 74 |.:- defi|ne_print|
|00000e60| 28 70 72 69 6e 74 5f 63 | 6f 6d 6d 61 6e 64 5f 62 |(print_c|ommand_b|
|00000e70| 6f 78 2c 20 70 72 69 6e | 74 5f 63 6f 6d 6d 61 6e |ox, prin|t_comman|
|00000e80| 64 29 2e 0d 0d 2f 2a 0d | 20 2a 20 43 6f 6d 6d 61 |d).../*.| * Comma|
|00000e90| 6e 64 20 23 31 3a 20 20 | 4d 6f 76 65 20 74 6f 20 |nd #1: |Move to |
|00000ea0| 74 68 65 20 6c 65 66 74 | 20 6d 61 72 67 69 6e 20 |the left| margin |
|00000eb0| 61 6e 64 20 70 72 69 6e | 74 20 74 68 65 20 6c 65 |and prin|t the le|
|00000ec0| 66 74 2f 72 69 67 68 74 | 20 70 61 72 65 6e 74 68 |ft/right| parenth|
|00000ed0| 65 73 69 73 2e 0d 20 2a | 2f 0d 70 72 69 6e 74 5f |esis.. *|/.print_|
|00000ee0| 63 6f 6d 6d 61 6e 64 28 | 31 2c 20 49 74 65 6d 29 |command(|1, Item)|
|00000ef0| 20 3a 2d 0d 09 70 70 6e | 6c 2c 0d 09 70 72 69 6e | :-..ppn|l,..prin|
|00000f00| 74 73 74 72 69 6e 67 28 | 49 74 65 6d 29 2e 0d 0d |tstring(|Item)...|
|00000f10| 2f 2a 0d 20 2a 20 43 6f | 6d 6d 61 6e 64 20 23 32 |/*. * Co|mmand #2|
|00000f20| 3a 20 50 72 69 6e 74 20 | 74 68 65 20 67 69 76 65 |: Print |the give|
|00000f30| 6e 20 6c 69 73 74 20 73 | 70 65 63 69 61 6c 6c 79 |n list s|pecially|
|00000f40| 20 28 76 65 72 74 69 63 | 61 6c 6c 79 29 2e 0d 20 | (vertic|ally).. |
|00000f50| 2a 2f 0d 70 72 69 6e 74 | 5f 63 6f 6d 6d 61 6e 64 |*/.print|_command|
|00000f60| 28 32 2c 20 4c 69 73 74 | 29 20 3a 2d 0d 09 70 72 |(2, List|) :-..pr|
|00000f70| 69 6e 74 5f 76 65 72 74 | 69 63 61 6c 5f 6c 69 73 |int_vert|ical_lis|
|00000f80| 74 28 4c 69 73 74 29 2e | 0d 0d 64 6f 5f 73 70 65 |t(List).|..do_spe|
|00000f90| 63 69 61 6c 5f 70 72 69 | 6e 74 5f 63 6f 6d 6d 61 |cial_pri|nt_comma|
|00000fa0| 6e 64 28 4c 65 66 74 4d | 61 72 67 69 6e 2c 20 4e |nd(LeftM|argin, N|
|00000fb0| 75 6d 2c 20 49 74 65 6d | 29 20 3a 2d 0d 09 63 72 |um, Item|) :-..cr|
|00000fc0| 65 61 74 65 28 70 72 69 | 6e 74 5f 63 6f 6d 6d 61 |eate(pri|nt_comma|
|00000fd0| 6e 64 5f 62 6f 78 2c 20 | 50 43 42 2c 20 4e 75 6d |nd_box, |PCB, Num|
|00000fe0| 2c 20 49 74 65 6d 29 2c | 0d 09 70 70 70 72 69 6e |, Item),|..ppprin|
|00000ff0| 74 5f 77 69 74 68 5f 6c | 65 66 74 5f 6d 61 72 67 |t_with_l|eft_marg|
|00001000| 69 6e 28 4c 65 66 74 4d | 61 72 67 69 6e 2c 20 50 |in(LeftM|argin, P|
|00001010| 43 42 29 2e 0d 0d 2f 2a | 0d 20 2a 20 41 20 70 72 |CB).../*|. * A pr|
|00001020| 69 6e 74 20 66 75 6e 63 | 74 69 6f 6e 20 74 6f 20 |int func|tion to |
|00001030| 62 65 20 75 73 65 64 20 | 77 69 74 68 20 6e 75 6d |be used |with num|
|00001040| 62 65 72 76 61 72 73 2c | 0d 20 2a 09 74 68 61 74 |bervars,|. *.that|
|00001050| 20 63 61 75 73 65 73 20 | 74 68 65 20 76 61 72 69 | causes |the vari|
|00001060| 61 62 6c 65 73 20 74 68 | 61 74 20 61 72 65 20 62 |ables th|at are b|
|00001070| 6f 75 6e 64 0d 20 2a 09 | 62 79 20 6e 75 6d 62 65 |ound. *.|by numbe|
|00001080| 72 20 76 61 72 73 20 74 | 6f 20 70 72 69 6e 74 20 |r vars t|o print |
|00001090| 6a 75 73 74 20 6c 69 6b | 65 20 76 61 72 69 61 62 |just lik|e variab|
|000010a0| 6c 65 73 2e 0d 20 2a 20 | 57 65 20 64 6f 20 6e 6f |les.. * |We do no|
|000010b0| 74 20 69 6e 73 74 61 6c | 6c 20 74 68 69 73 20 61 |t instal|l this a|
|000010c0| 73 20 61 20 64 65 66 61 | 75 6c 74 20 73 69 6e 63 |s a defa|ult sinc|
|000010d0| 65 3a 20 74 68 69 73 20 | 63 61 6e 20 62 65 20 76 |e: this |can be v|
|000010e0| 65 72 79 20 63 6f 6e 66 | 75 73 69 6e 67 3b 0d 20 |ery conf|using;. |
|000010f0| 2a 09 77 65 20 77 69 6c | 6c 20 73 65 65 20 76 61 |*.we wil|l see va|
|00001100| 72 69 61 62 6c 65 73 20 | 77 68 69 63 68 20 61 72 |riables |which ar|
|00001110| 65 20 72 65 61 6c 6c 79 | 20 62 6f 75 6e 64 20 74 |e really| bound t|
|00001120| 6f 20 27 24 56 41 52 27 | 28 4e 29 2e 0d 20 2a 0d |o '$VAR'|(N).. *.|
|00001130| 20 2a 20 53 6f 20 77 65 | 20 6d 61 6b 65 20 74 68 | * So we| make th|
|00001140| 69 73 20 70 72 69 6e 74 | 20 76 61 72 69 61 62 6c |is print| variabl|
|00001150| 65 20 77 69 74 68 20 74 | 68 65 20 70 72 65 66 61 |e with t|he prefa|
|00001160| 63 65 20 5f 56 2e 0d 20 | 2a 2f 0d 70 72 69 6e 74 |ce _V.. |*/.print|
|00001170| 5f 6e 75 6d 62 65 72 76 | 61 72 5f 76 61 72 28 27 |_numberv|ar_var('|
|00001180| 24 56 41 52 27 28 4e 29 | 29 20 3a 2d 0d 09 28 4e |$VAR'(N)|) :-..(N|
|00001190| 20 3d 20 27 24 56 41 52 | 27 28 4d 29 20 2d 3e 20 | = '$VAR|'(M) -> |
|000011a0| 77 72 69 74 65 28 27 24 | 56 41 52 27 29 2c 20 77 |write('$|VAR'), w|
|000011b0| 72 69 74 65 28 27 28 5f | 27 29 2c 77 72 69 74 65 |rite('(_|'),write|
|000011c0| 28 4d 29 2c 77 72 69 74 | 65 28 27 29 27 29 0d 09 |(M),writ|e(')')..|
|000011d0| 3b 70 75 74 28 27 5f 27 | 29 2c 70 75 74 28 27 56 |;put('_'|),put('V|
|000011e0| 27 29 2c 77 72 69 74 65 | 28 4e 29 29 2e 0d 09 0d |'),write|(N))....|
|000011f0| 3a 2d 20 64 65 66 69 6e | 65 5f 70 72 69 6e 74 28 |:- defin|e_print(|
|00001200| 27 24 56 41 52 27 2f 31 | 2c 20 70 72 69 6e 74 5f |'$VAR'/1|, print_|
|00001210| 6e 75 6d 62 65 72 76 61 | 72 5f 76 61 72 29 2e 0d |numberva|r_var)..|
|00001220| 09 0d 70 72 69 6e 74 5f | 76 65 72 74 69 63 61 6c |..print_|vertical|
|00001230| 5f 6c 69 73 74 5f 6f 6e | 65 5f 69 74 65 6d 28 49 |_list_on|e_item(I|
|00001240| 74 65 6d 29 20 3a 2d 0d | 09 2f 2a 0d 09 20 2a 20 |tem) :-.|./*.. * |
|00001250| 47 6f 74 6f 20 74 68 65 | 20 63 75 72 72 65 6e 74 |Goto the| current|
|00001260| 20 6c 65 66 74 20 6d 61 | 72 67 69 6e 2e 0d 09 20 | left ma|rgin... |
|00001270| 2a 2f 0d 09 70 70 6e 6c | 2c 0d 09 2f 2a 0d 09 20 |*/..ppnl|,../*.. |
|00001280| 2a 20 57 65 20 68 61 76 | 65 20 68 61 72 64 77 69 |* We hav|e hardwi|
|00001290| 72 65 64 20 74 68 65 20 | 70 72 65 63 65 64 65 6e |red the |preceden|
|000012a0| 63 65 20 66 6f 72 20 74 | 68 65 20 63 6f 6d 6d 61 |ce for t|he comma|
|000012b0| 20 6f 70 65 72 61 74 6f | 72 20 68 65 72 65 2e 0d | operato|r here..|
|000012c0| 09 20 2a 2f 0d 09 70 72 | 69 6e 74 5f 77 69 74 68 |. */..pr|int_with|
|000012d0| 5f 70 72 65 63 65 64 65 | 6e 63 65 28 39 39 39 2c |_precede|nce(999,|
|000012e0| 20 49 74 65 6d 29 2e 0d | 09 0d 2f 2a 0d 20 2a 20 | Item)..|../*. * |
|000012f0| 54 68 69 73 20 77 69 6c | 6c 20 70 72 69 6e 74 20 |This wil|l print |
|00001300| 6f 75 74 20 61 20 6c 69 | 73 74 20 6f 66 20 67 6f |out a li|st of go|
|00001310| 61 6c 73 0d 20 2a 09 75 | 73 65 64 20 62 79 20 74 |als. *.u|sed by t|
|00001320| 68 65 20 6f 74 68 65 72 | 20 66 75 6e 63 74 69 6f |he other| functio|
|00001330| 6e 73 20 69 6e 20 74 68 | 69 73 20 66 69 6c 65 2e |ns in th|is file.|
|00001340| 0d 20 2a 2f 0d 70 72 69 | 6e 74 5f 76 65 72 74 69 |. */.pri|nt_verti|
|00001350| 63 61 6c 5f 6c 69 73 74 | 28 4c 29 20 3a 2d 0d 09 |cal_list|(L) :-..|
|00001360| 6e 6f 74 28 6c 69 73 74 | 28 4c 29 29 2c 0d 09 21 |not(list|(L)),..!|
|00001370| 2c 0d 09 70 72 69 6e 74 | 5f 76 65 72 74 69 63 61 |,..print|_vertica|
|00001380| 6c 5f 6c 69 73 74 5f 6f | 6e 65 5f 69 74 65 6d 28 |l_list_o|ne_item(|
|00001390| 4c 29 2e 0d 70 72 69 6e | 74 5f 76 65 72 74 69 63 |L)..prin|t_vertic|
|000013a0| 61 6c 5f 6c 69 73 74 28 | 5b 4f 6e 65 49 74 65 6d |al_list(|[OneItem|
|000013b0| 5d 29 20 3a 2d 0d 09 21 | 2c 0d 09 70 72 69 6e 74 |]) :-..!|,..print|
|000013c0| 5f 76 65 72 74 69 63 61 | 6c 5f 6c 69 73 74 5f 6f |_vertica|l_list_o|
|000013d0| 6e 65 5f 69 74 65 6d 28 | 4f 6e 65 49 74 65 6d 29 |ne_item(|OneItem)|
|000013e0| 2e 0d 70 72 69 6e 74 5f | 76 65 72 74 69 63 61 6c |..print_|vertical|
|000013f0| 5f 6c 69 73 74 28 5b 46 | 69 72 73 74 7c 52 65 73 |_list([F|irst|Res|
|00001400| 74 5d 29 20 3a 2d 0d 09 | 70 72 69 6e 74 5f 76 65 |t]) :-..|print_ve|
|00001410| 72 74 69 63 61 6c 5f 6c | 69 73 74 5f 6f 6e 65 5f |rtical_l|ist_one_|
|00001420| 69 74 65 6d 28 46 69 72 | 73 74 29 2c 0d 09 70 75 |item(Fir|st),..pu|
|00001430| 74 28 27 2c 27 29 2c 70 | 75 74 28 27 20 27 29 2c |t(','),p|ut(' '),|
|00001440| 09 09 2f 2a 20 57 65 20 | 70 72 69 6e 74 20 74 68 |../* We |print th|
|00001450| 65 20 73 70 61 63 65 20 | 69 6e 20 63 61 73 65 20 |e space |in case |
|00001460| 77 65 20 61 72 65 20 6e | 6f 74 20 70 72 65 74 74 |we are n|ot prett|
|00001470| 79 20 70 72 69 6e 74 69 | 6e 67 20 2a 2f 0d 09 70 |y printi|ng */..p|
|00001480| 72 69 6e 74 5f 76 65 72 | 74 69 63 61 6c 5f 6c 69 |rint_ver|tical_li|
|00001490| 73 74 28 52 65 73 74 29 | 2e 0d 0d 2f 2a 0d 20 2a |st(Rest)|.../*. *|
|000014a0| 20 54 68 69 73 20 64 65 | 66 69 6e 65 73 20 61 20 | This de|fines a |
|000014b0| 73 69 6d 70 6c 65 20 70 | 72 69 6e 74 20 66 75 6e |simple p|rint fun|
|000014c0| 63 74 69 6f 6e 20 66 6f | 72 20 74 68 65 20 3b 20 |ction fo|r the ; |
|000014d0| 6f 70 65 72 61 74 6f 72 | 2e 0d 20 2a 2f 0d 70 72 |operator|.. */.pr|
|000014e0| 69 6e 74 5f 6f 72 28 4d | 61 73 74 65 72 4f 72 43 |int_or(M|asterOrC|
|000014f0| 6c 61 75 73 65 29 20 3a | 2d 0d 09 70 70 6e 6c 2c |lause) :|-..ppnl,|
|00001500| 09 09 2f 2a 20 46 6f 72 | 63 65 20 6d 6f 76 65 20 |../* For|ce move |
|00001510| 74 6f 20 63 75 72 72 65 | 6e 74 20 6c 65 66 74 20 |to curre|nt left |
|00001520| 6d 61 72 67 69 6e 20 69 | 66 20 70 72 65 74 74 79 |margin i|f pretty|
|00001530| 20 70 72 69 6e 74 69 6e | 67 20 2a 2f 0d 09 25 0d | printin|g */..%.|
|00001540| 09 25 20 57 65 20 6d 75 | 73 74 20 63 6f 70 79 20 |.% We mu|st copy |
|00001550| 69 74 2c 20 62 65 63 61 | 75 73 65 20 70 72 69 6e |it, beca|use prin|
|00001560| 74 20 73 68 6f 75 6c 64 | 20 6e 6f 74 20 61 73 73 |t should| not ass|
|00001570| 69 67 6e 20 76 61 6c 75 | 65 73 20 74 6f 20 76 61 |ign valu|es to va|
|00001580| 72 69 61 62 6c 65 73 2e | 0d 09 25 09 70 61 73 73 |riables.|..%.pass|
|00001590| 65 64 20 74 6f 20 69 74 | 2e 0d 09 63 6f 70 79 28 |ed to it|...copy(|
|000015a0| 4d 61 73 74 65 72 4f 72 | 43 6c 61 75 73 65 2c 20 |MasterOr|Clause, |
|000015b0| 4f 72 43 6c 61 75 73 65 | 29 2c 0d 09 25 0d 09 25 |OrClause|),..%..%|
|000015c0| 20 57 65 20 6d 75 73 74 | 20 72 65 70 6c 61 63 65 | We must| replace|
|000015d0| 20 6e 75 6d 62 65 72 73 | 20 77 69 74 68 20 27 24 | numbers| with '$|
|000015e0| 56 41 52 27 20 63 6c 61 | 75 73 65 73 0d 09 25 20 |VAR' cla|uses..% |
|000015f0| 75 73 69 6e 67 20 6e 75 | 6d 62 65 72 76 61 72 73 |using nu|mbervars|
|00001600| 2f 33 2e 0d 09 25 20 49 | 66 20 6e 6f 74 2c 20 76 |/3...% I|f not, v|
|00001610| 61 72 69 61 62 6c 65 20 | 61 72 65 20 63 6f 70 69 |ariable |are copi|
|00001620| 65 64 20 77 68 65 6e 20 | 70 6c 61 63 65 64 20 69 |ed when |placed i|
|00001630| 6e 73 69 64 65 20 74 68 | 65 20 70 72 69 6e 74 5f |nside th|e print_|
|00001640| 63 6f 6d 6d 61 6e 64 5f | 62 6f 78 2c 0d 09 25 20 |command_|box,..% |
|00001650| 61 6e 64 20 74 68 65 79 | 20 77 69 6c 6c 20 6e 6f |and they| will no|
|00001660| 74 20 68 61 76 65 20 74 | 68 65 20 73 61 6d 65 20 |t have t|he same |
|00001670| 76 61 6c 75 65 20 77 68 | 65 6e 20 70 72 69 6e 74 |value wh|en print|
|00001680| 65 64 20 69 6e 20 64 69 | 66 66 65 72 65 6e 74 20 |ed in di|fferent |
|00001690| 6c 6f 63 61 74 69 6f 6e | 73 2e 0d 09 25 0d 09 6e |location|s...%..n|
|000016a0| 75 6d 62 65 72 76 61 72 | 73 28 4f 72 43 6c 61 75 |umbervar|s(OrClau|
|000016b0| 73 65 2c 20 31 2c 20 5f | 29 2c 0d 09 4f 72 43 6c |se, 1, _|),..OrCl|
|000016c0| 61 75 73 65 20 3d 20 3b | 28 46 69 72 73 74 2c 53 |ause = ;|(First,S|
|000016d0| 65 63 6f 6e 64 29 2c 0d | 09 63 75 72 72 65 6e 74 |econd),.|.current|
|000016e0| 5f 6c 65 66 74 5f 6d 61 | 72 67 69 6e 28 4c 65 66 |_left_ma|rgin(Lef|
|000016f0| 74 4d 61 72 67 69 6e 29 | 2c 0d 09 2f 2a 0d 09 20 |tMargin)|,../*.. |
|00001700| 2a 20 49 66 20 70 72 65 | 63 65 64 65 6e 63 65 20 |* If pre|cedence |
|00001710| 61 74 20 63 65 72 74 61 | 69 6e 20 6c 65 76 65 6c |at certa|in level|
|00001720| 2c 20 77 65 20 6e 65 65 | 64 20 74 6f 20 70 6c 61 |, we nee|d to pla|
|00001730| 63 65 20 70 61 72 65 6e | 74 68 65 73 69 73 0d 09 |ce paren|thesis..|
|00001740| 20 2a 2f 0d 09 28 09 63 | 75 72 72 65 6e 74 5f 70 | */..(.c|urrent_p|
|00001750| 72 65 63 65 64 65 6e 63 | 65 20 3c 20 31 31 30 30 |recedenc|e < 1100|
|00001760| 20 2d 3e 20 0d 09 09 09 | 4f 72 4c 65 66 74 4d 61 | -> ....|OrLeftMa|
|00001770| 72 67 69 6e 20 69 73 20 | 4c 65 66 74 4d 61 72 67 |rgin is |LeftMarg|
|00001780| 69 6e 2c 0d 09 09 09 64 | 6f 5f 73 70 65 63 69 61 |in,....d|o_specia|
|00001790| 6c 5f 70 72 69 6e 74 5f | 63 6f 6d 6d 61 6e 64 28 |l_print_|command(|
|000017a0| 4f 72 4c 65 66 74 4d 61 | 72 67 69 6e 2c 20 31 2c |OrLeftMa|rgin, 1,|
|000017b0| 20 20 22 28 20 22 29 0d | 09 3b 09 0d 09 09 28 4c | "( ").|.;....(L|
|000017c0| 65 66 74 4d 61 72 67 69 | 6e 20 3d 3a 3d 20 30 20 |eftMargi|n =:= 0 |
|000017d0| 2d 3e 20 4f 72 4c 65 66 | 74 4d 61 72 67 69 6e 20 |-> OrLef|tMargin |
|000017e0| 69 73 20 30 20 3b 20 4f | 72 4c 65 66 74 4d 61 72 |is 0 ; O|rLeftMar|
|000017f0| 67 69 6e 20 69 73 20 4c | 65 66 74 4d 61 72 67 69 |gin is L|eftMargi|
|00001800| 6e 20 2d 20 31 29 0d 09 | 29 2c 0d 09 70 72 69 6e |n - 1)..|),..prin|
|00001810| 74 5f 6f 72 31 28 46 69 | 72 73 74 2c 20 53 65 63 |t_or1(Fi|rst, Sec|
|00001820| 6f 6e 64 2c 20 4c 65 66 | 74 4d 61 72 67 69 6e 2c |ond, Lef|tMargin,|
|00001830| 20 4f 72 4c 65 66 74 4d | 61 72 67 69 6e 29 2e 0d | OrLeftM|argin)..|
|00001840| 09 0d 70 72 69 6e 74 5f | 6f 72 31 28 46 69 72 73 |..print_|or1(Firs|
|00001850| 74 2c 20 53 65 63 6f 6e | 64 2c 20 4c 65 66 74 4d |t, Secon|d, LeftM|
|00001860| 61 72 67 69 6e 2c 20 4f | 72 4c 65 66 74 4d 61 72 |argin, O|rLeftMar|
|00001870| 67 69 6e 29 20 3a 2d 0d | 09 49 74 65 6d 4c 65 66 |gin) :-.|.ItemLef|
|00001880| 74 4d 61 72 67 69 6e 20 | 69 73 20 4c 65 66 74 4d |tMargin |is LeftM|
|00001890| 61 72 67 69 6e 20 2b 20 | 32 2c 0d 09 70 72 69 6e |argin + |2,..prin|
|000018a0| 74 5f 67 6f 61 6c 5f 6c | 69 73 74 28 46 69 72 73 |t_goal_l|ist(Firs|
|000018b0| 74 2c 20 49 74 65 6d 4c | 65 66 74 4d 61 72 67 69 |t, ItemL|eftMargi|
|000018c0| 6e 29 2c 0d 09 64 6f 5f | 73 70 65 63 69 61 6c 5f |n),..do_|special_|
|000018d0| 70 72 69 6e 74 5f 63 6f | 6d 6d 61 6e 64 28 4f 72 |print_co|mmand(Or|
|000018e0| 4c 65 66 74 4d 61 72 67 | 69 6e 2c 20 31 2c 20 22 |LeftMarg|in, 1, "|
|000018f0| 3b 20 22 29 2c 0d 09 28 | 09 53 65 63 6f 6e 64 20 |; "),..(|.Second |
|00001900| 3d 20 5b 3b 28 4e 46 69 | 72 73 74 2c 20 4e 53 65 |= [;(NFi|rst, NSe|
|00001910| 63 6f 6e 64 29 5d 20 2d | 3e 20 0d 09 09 09 70 72 |cond)] -|> ....pr|
|00001920| 69 6e 74 5f 6f 72 31 28 | 4e 46 69 72 73 74 2c 20 |int_or1(|NFirst, |
|00001930| 4e 53 65 63 6f 6e 64 2c | 20 4c 65 66 74 4d 61 72 |NSecond,| LeftMar|
|00001940| 67 69 6e 2c 20 4f 72 4c | 65 66 74 4d 61 72 67 69 |gin, OrL|eftMargi|
|00001950| 6e 29 0d 09 3b 09 70 72 | 69 6e 74 5f 67 6f 61 6c |n)..;.pr|int_goal|
|00001960| 5f 6c 69 73 74 28 53 65 | 63 6f 6e 64 2c 20 49 74 |_list(Se|cond, It|
|00001970| 65 6d 4c 65 66 74 4d 61 | 72 67 69 6e 29 2c 0d 09 |emLeftMa|rgin),..|
|00001980| 09 28 09 63 75 72 72 65 | 6e 74 5f 70 72 65 63 65 |.(.curre|nt_prece|
|00001990| 64 65 6e 63 65 20 3c 20 | 31 31 30 30 20 2d 3e 20 |dence < |1100 -> |
|000019a0| 64 6f 5f 73 70 65 63 69 | 61 6c 5f 70 72 69 6e 74 |do_speci|al_print|
|000019b0| 5f 63 6f 6d 6d 61 6e 64 | 28 4f 72 4c 65 66 74 4d |_command|(OrLeftM|
|000019c0| 61 72 67 69 6e 2c 20 31 | 2c 20 22 29 22 29 0d 09 |argin, 1|, ")")..|
|000019d0| 09 3b 09 74 72 75 65 0d | 09 09 29 0d 09 29 2e 0d |.;.true.|..)..)..|
|000019e0| 0d 70 72 69 6e 74 5f 67 | 6f 61 6c 5f 6c 69 73 74 |.print_g|oal_list|
|000019f0| 28 4c 69 73 74 2c 20 4d | 61 72 67 69 6e 29 20 3a |(List, M|argin) :|
|00001a00| 2d 0d 09 63 72 65 61 74 | 65 28 70 72 69 6e 74 5f |-..creat|e(print_|
|00001a10| 63 6f 6d 6d 61 6e 64 5f | 62 6f 78 2c 20 50 43 42 |command_|box, PCB|
|00001a20| 2c 20 32 2c 20 4c 69 73 | 74 29 2c 0d 09 70 70 70 |, 2, Lis|t),..ppp|
|00001a30| 72 69 6e 74 5f 77 69 74 | 68 5f 6c 65 66 74 5f 6d |rint_wit|h_left_m|
|00001a40| 61 72 67 69 6e 28 4d 61 | 72 67 69 6e 2c 20 50 43 |argin(Ma|rgin, PC|
|00001a50| 42 29 2e 0d 0d 3a 2d 20 | 64 65 66 69 6e 65 5f 70 |B)...:- |define_p|
|00001a60| 72 69 6e 74 28 28 3b 29 | 2f 32 2c 20 70 72 69 6e |rint((;)|/2, prin|
|00001a70| 74 5f 6f 72 29 2e 0d 0d | 2f 2a 0d 20 2a 20 54 68 |t_or)...|/*. * Th|
|00001a80| 69 73 20 63 61 6e 20 62 | 65 20 75 73 65 64 20 61 |is can b|e used a|
|00001a90| 73 20 61 20 73 69 6d 70 | 6c 65 20 70 72 69 6e 74 |s a simp|le print|
|00001aa0| 69 6e 67 20 6f 66 20 72 | 75 6c 65 73 2e 0d 20 2a |ing of r|ules.. *|
|00001ab0| 2f 0d 70 72 69 6e 74 5f | 72 75 6c 65 28 4d 61 73 |/.print_|rule(Mas|
|00001ac0| 74 65 72 52 75 6c 65 29 | 20 3a 2d 20 0d 09 25 0d |terRule)| :- ..%.|
|00001ad0| 09 25 20 57 65 20 6d 75 | 73 74 20 63 6f 70 79 20 |.% We mu|st copy |
|00001ae0| 69 74 2c 20 62 65 63 61 | 75 73 65 20 70 72 69 6e |it, beca|use prin|
|00001af0| 74 20 73 68 6f 75 6c 64 | 20 6e 6f 74 20 61 73 73 |t should| not ass|
|00001b00| 69 67 6e 20 76 61 6c 75 | 65 73 20 74 6f 20 76 61 |ign valu|es to va|
|00001b10| 72 69 61 62 6c 65 73 2e | 0d 09 25 09 70 61 73 73 |riables.|..%.pass|
|00001b20| 65 64 20 74 6f 20 69 74 | 2e 0d 09 63 6f 70 79 28 |ed to it|...copy(|
|00001b30| 4d 61 73 74 65 72 52 75 | 6c 65 2c 20 52 75 6c 65 |MasterRu|le, Rule|
|00001b40| 29 2c 0d 09 25 0d 09 25 | 20 57 65 20 6d 75 73 74 |),..%..%| We must|
|00001b50| 20 72 65 70 6c 61 63 65 | 20 6e 75 6d 62 65 72 73 | replace| numbers|
|00001b60| 20 77 69 74 68 20 27 24 | 56 41 52 27 20 63 6c 61 | with '$|VAR' cla|
|00001b70| 75 73 65 73 0d 09 25 20 | 75 73 69 6e 67 20 6e 75 |uses..% |using nu|
|00001b80| 6d 62 65 72 76 61 72 73 | 2f 33 2e 0d 09 25 20 49 |mbervars|/3...% I|
|00001b90| 66 20 6e 6f 74 2c 20 76 | 61 72 69 61 62 6c 65 20 |f not, v|ariable |
|00001ba0| 61 72 65 20 63 6f 70 69 | 65 64 20 77 68 65 6e 20 |are copi|ed when |
|00001bb0| 70 6c 61 63 65 64 20 69 | 6e 73 69 64 65 20 74 68 |placed i|nside th|
|00001bc0| 65 20 70 72 69 6e 74 5f | 63 6f 6d 6d 61 6e 64 5f |e print_|command_|
|00001bd0| 62 6f 78 2c 0d 09 25 20 | 61 6e 64 20 74 68 65 79 |box,..% |and they|
|00001be0| 20 77 69 6c 6c 20 6e 6f | 74 20 68 61 76 65 20 74 | will no|t have t|
|00001bf0| 68 65 20 73 61 6d 65 20 | 76 61 6c 75 65 20 77 68 |he same |value wh|
|00001c00| 65 6e 20 70 72 69 6e 74 | 65 64 20 69 6e 20 64 69 |en print|ed in di|
|00001c10| 66 66 65 72 65 6e 74 20 | 6c 6f 63 61 74 69 6f 6e |fferent |location|
|00001c20| 73 2e 0d 09 25 0d 09 6e | 75 6d 62 65 72 76 61 72 |s...%..n|umbervar|
|00001c30| 73 28 52 75 6c 65 2c 20 | 31 2c 20 5f 29 2c 0d 09 |s(Rule, |1, _),..|
|00001c40| 52 75 6c 65 20 3d 20 3a | 2d 28 48 65 61 64 2c 20 |Rule = :|-(Head, |
|00001c50| 54 61 69 6c 29 2c 0d 09 | 70 70 6e 6c 2c 09 09 09 |Tail),..|ppnl,...|
|00001c60| 2f 2a 20 46 6f 72 63 65 | 20 6d 6f 76 65 20 74 6f |/* Force| move to|
|00001c70| 20 63 75 72 72 65 6e 74 | 20 6c 65 66 74 20 6d 61 | current| left ma|
|00001c80| 72 67 69 6e 20 69 66 20 | 70 72 65 74 74 79 20 70 |rgin if |pretty p|
|00001c90| 72 69 6e 74 69 6e 67 20 | 2a 2f 0d 09 63 75 72 72 |rinting |*/..curr|
|00001ca0| 65 6e 74 5f 6c 65 66 74 | 5f 6d 61 72 67 69 6e 28 |ent_left|_margin(|
|00001cb0| 4c 65 66 74 4d 61 72 67 | 69 6e 29 2c 0d 09 70 72 |LeftMarg|in),..pr|
|00001cc0| 69 6e 74 28 48 65 61 64 | 29 2c 0d 09 77 72 69 74 |int(Head|),..writ|
|00001cd0| 65 28 27 20 3a 2d 20 27 | 29 2c 0d 09 70 72 69 6e |e(' :- '|),..prin|
|00001ce0| 74 5f 67 6f 61 6c 5f 6c | 69 73 74 28 54 61 69 6c |t_goal_l|ist(Tail|
|00001cf0| 2c 20 4c 65 66 74 4d 61 | 72 67 69 6e 20 2b 20 34 |, LeftMa|rgin + 4|
|00001d00| 29 2e 0d 09 0d 3a 2d 20 | 64 65 66 69 6e 65 5f 70 |)....:- |define_p|
|00001d10| 72 69 6e 74 28 28 3a 2d | 29 2f 32 2c 20 70 72 69 |rint((:-|)/2, pri|
|00001d20| 6e 74 5f 72 75 6c 65 29 | 2e 0d 0d 2f 2a 0d 20 2a |nt_rule)|.../*. *|
|00001d30| 20 49 66 20 77 65 20 77 | 65 72 65 20 74 6f 20 63 | If we w|ere to c|
|00001d40| 61 6c 6c 20 70 72 69 6e | 74 20 77 69 74 68 20 74 |all prin|t with t|
|00001d50| 68 65 20 3b 20 73 79 6d | 62 6f 6c 2c 20 77 65 20 |he ; sym|bol, we |
|00001d60| 6d 69 67 68 74 20 67 65 | 74 20 70 61 72 65 6e 74 |might ge|t parent|
|00001d70| 68 65 73 69 73 0d 20 2a | 09 61 72 6f 75 6e 64 20 |hesis. *|.around |
|00001d80| 69 74 2e 20 20 0d 20 2a | 20 54 68 65 20 66 6f 6c |it. . *| The fol|
|00001d90| 6c 6f 77 69 6e 67 20 63 | 61 6e 20 62 65 20 64 6f |lowing c|an be do|
|00001da0| 6e 65 20 74 6f 20 70 72 | 69 6e 74 20 74 68 65 20 |ne to pr|int the |
|00001db0| 73 65 6d 69 63 6f 6c 6f | 6e 20 77 69 74 68 6f 75 |semicolo|n withou|
|00001dc0| 74 20 70 61 72 65 6e 74 | 68 65 73 69 73 2e 0d 20 |t parent|hesis.. |
|00001dd0| 2a 20 57 65 20 61 72 65 | 20 6e 6f 74 20 75 73 69 |* We are| not usi|
|00001de0| 6e 67 20 74 68 69 73 2e | 0d 0d 70 72 69 6e 74 5f |ng this.|..print_|
|00001df0| 73 65 6d 69 63 6f 6c 6f | 6e 28 5f 29 20 3a 2d 20 |semicolo|n(_) :- |
|00001e00| 70 75 74 28 60 3b 60 29 | 2e 0d 0d 3a 2d 20 64 65 |put(`;`)|...:- de|
|00001e10| 66 69 6e 65 5f 70 72 69 | 6e 74 28 28 3b 29 2f 30 |fine_pri|nt((;)/0|
|00001e20| 2c 20 70 72 69 6e 74 5f | 73 65 6d 69 63 6f 6c 6f |, print_|semicolo|
|00001e30| 6e 29 2e 0d 0d 20 2a 2f | 0d 00 00 00 00 00 00 00 |n)... */|........|
|00001e40| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001e50| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001e60| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001e70| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001e80| 00 00 01 00 00 00 01 22 | 00 00 00 22 00 00 00 5a |......."|..."...Z|
|00001e90| 74 69 6f 6e 73 2e 70 3a | 20 53 6f 6d 65 20 62 61 |tions.p:| Some ba|
|00001ea0| 73 69 63 20 41 64 76 61 | 6e 63 65 64 20 41 2e 49 |sic Adva|nced A.I|
|00001eb0| 11 64 65 66 69 6e 65 5f | 70 72 69 6e 74 20 65 78 |.define_|print ex|
|00001ec0| 2e 70 02 00 00 00 54 45 | 58 54 41 49 46 43 01 00 |.p....TE|XTAIFC..|
|00001ed0| 00 00 54 45 58 54 41 49 | 46 43 01 00 00 3c 00 00 |..TEXTAI|FC...<..|
|00001ee0| 00 00 00 00 00 00 00 00 | 00 00 00 00 00 00 00 00 |........|........|
|00001ef0| 00 00 a5 78 f3 03 00 00 | 1d b9 00 00 01 7c 53 79 |...x....|.....|Sy|
|00001f00| 73 74 65 6d 73 2c 20 49 | 6e 63 2e 0d 20 2a 20 41 |stems, I|nc.. * A|
|00001f10| 6c 6c 20 72 69 67 68 74 | 73 20 72 65 73 65 72 76 |ll right|s reserv|
|00001f20| 65 64 2e 0d 20 2a 0d 20 | 2a 2f 0d 3a 2d 20 73 65 |ed.. *. |*/.:- se|
|00001f30| 74 70 61 63 6b 61 67 65 | 28 70 72 6f 6c 6f 67 29 |tpackage|(prolog)|
|00001f40| 2e 0d 0d 6d 65 6d 62 65 | 72 28 41 2c 5b 41 7c 5f |...membe|r(A,[A|_|
|00001f50| 5d 29 2e 0d 6d 65 6d 62 | 65 72 28 41 2c 5b 5f 7c |])..memb|er(A,[_||
|00001f60| 42 5d 29 20 3a 2d 20 6d | 65 6d 62 65 72 28 41 2c |B]) :- m|ember(A,|
|00001f70| 42 29 2e 0d 0d 61 70 70 | 65 6e 64 28 5b 5d 2c 41 |B)...app|end([],A|
|00001f80| 00 00 00 0a 00 09 06 47 | 65 6e 65 76 61 08 00 00 |.......G|eneva...|
|00001f90| 00 08 00 81 00 08 01 53 | 01 ec 00 00 00 04 00 18 |.......S|........|
|00001fa0| 00 08 00 00 01 00 00 00 | 01 22 00 00 00 22 00 00 |........|."..."..|
|00001fb0| 00 5a 00 1c f0 b0 08 d2 | 00 00 00 1c 00 5a 00 02 |.Z......|.....Z..|
|00001fc0| 45 46 4e 54 00 00 00 1a | 45 57 4e 44 00 00 00 26 |EFNT....|EWND...&|
|00001fd0| 45 54 41 42 00 00 00 32 | 03 eb ff ff 00 00 00 00 |ETAB...2|........|
|00001fe0| 00 1d 3b 8c 01 00 ff ff | 00 00 00 0e 00 1d 3a a0 |..;.....|......:.|
|00001ff0| 03 ec ff ff 00 00 00 1a | 00 1d 3b fc 00 00 00 00 |........|..;.....|
+--------+-------------------------+-------------------------+--------+--------+